package com.ed.controller;

import com.ed.domain.Response;
import com.ed.dto.PageQueryDto;
import com.ed.result.PageResult;
import com.ed.result.Result;
import com.ed.service.ResponseService;
import com.ed.vo.ResponseQAVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Slf4j
@CrossOrigin
@RequestMapping("/response")
public class ResponseController {
    @Autowired
    private ResponseService responseService;

    //分页查询个人答题记录
    @PostMapping("/myList")
    public Result<PageResult> myList(@RequestBody PageQueryDto dto){
        return Result.success(responseService.myResponseList(dto));
    }

    //根据答题记录，返回答题记录详情
    @PostMapping("/findDetailsByResult")
    public Result<List<ResponseQAVo>> findDetailsByResult(@RequestBody Response response){
        log.info("用户信息为,{}", response);
        List<ResponseQAVo> res = responseService.detailsByResponse(response);
        return Result.success(res);
    }
}
